package com.xbk.platform.junit;

import static org.junit.Assert.*;
import java.sql.SQLException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.xbk.platform.BusinessObject;
import com.xbk.platform.DaoUtil;
import com.xbk.platform.DataMap;
import com.xbk.platform.sql.ConnectionMananger;

public class DaoUtilTest {
	
	private DaoUtil du = null;

	@Before
	public void setUp() throws Exception {
		this.du = ConnectionMananger.getDaoUtil();
	}

	@After
	public void tearDown() throws Exception {
		this.du.close();
	}

	@Test
	public void getResult() throws SQLException {
		
		
		BusinessObject bo = new BusinessObject("USERID", "USER_INFO", this.du);
		DataMap data = new DataMap();
		data.put("USERID", "jUnitTester");
		bo.setBoData(data);
		
		bo.deleteDB();
		//bo.save();
		DataMap dataRS = du.getResult("SELECT * FROM USER_INFO WHERE USERID = 'jUnitTester'");
		assertNotNull(this.du.getConnection());
		assertEquals("jUnitTester", dataRS.get("USERID"));
	}

}
